package com.hsxxherp.ation.business.user.center.error;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 标准错误
 */
public enum AtionUserCenterErrorMsgEnum {

    /**
     * 内部错误
     */
    SYS_COMMON_ERROR("500", "未知错误，请通过rid查询具体详情"),

    /**
     * 登录失败
     */
    UCENTER_LOGIN_NOT_CHECK("5X-BUSINESS-UCENTER-00001", "登录失败！账号或密错误。");

    static final Map<String, String> valueMap = Maps.newHashMap();

    static {
        for (AtionUserCenterErrorMsgEnum value : AtionUserCenterErrorMsgEnum.values()) {
            valueMap.put(value.errorCode, value.errorMessage);
        }
    }

    private final String errorCode;

    //    ---  错误码翻译器  ---
    private final String errorMessage;

    AtionUserCenterErrorMsgEnum(String errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    /**
     * 通过错误代码查找其中文含义.
     */
    public static String findMsgByCode(String code) {
        return valueMap.getOrDefault(code, null);
    }

    // getter
    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}
